package com.qianfeng.test;

import android.app.Application;

import com.baidu.mapapi.SDKInitializer;
import com.handmark.pulltorefresh.library.internal.Utils;
import com.nostra13.universalimageloader.cache.disc.DiskCache;
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.qianfeng.test.utils.LocationHelper;

/**
 * Created by Administrator on 15-7-24.
 */
public class BaseApp extends Application{
    private static BaseApp app = null;
    @Override
    public void onCreate() {
        super.onCreate();
        app = this;
        initImageLoadGlobalConfig();
        initBaduMap();
        LocationHelper.init(this);
        LocationHelper.getInstance().start();
    }

    public static BaseApp getInstance(){//单例是干什么用的
        return app;
    }
    public void initBaduMap(){
        SDKInitializer.initialize(this);
    }
    private void initImageLoadGlobalConfig(){
        ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder(this);
        DiskCache cache = new UnlimitedDiskCache(com.qianfeng.test.utils.Utils.getImageCache());
        builder.diskCache(cache);
        builder.diskCacheFileCount(500);
        builder.diskCacheSize(50 * 1024 * 1024);
        int maxMemory = (int) Runtime.getRuntime().maxMemory();
        builder.memoryCacheSize(maxMemory / 8);
        builder.diskCacheFileNameGenerator(new Md5FileNameGenerator());
        ImageLoader.getInstance().init(builder.build());
    }


}
